<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>state</title>
  </head>
  <body>
    <div id="test"></div>
    <div id="test1"></div>
    <div id="test2"></div>

    <script
      src="https://unpkg.com/react@16/umd/react.development.js"
      crossorigin
    ></script>
    <script
      src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"
      crossorigin
    ></script>
    <script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
    <script type="text/babel"></script>
  </body>
  <script type="text/babel">
    //创建组件
    class Demo extends React.Component {
      //展示左侧输入框的内容
      showData = () => {
        alert(this.refs.input.value);
      };
      showData1 = () => {
        alert(this.refs.input1.value);
      };
      render() {
        return (
          <div>
            <input ref="input" type="text" placeholder="点击按钮提示数据" />
            &nbsp;
            <button onClick={this.showData}>点我提示左侧数据</button>
            &nbsp;
            <input
              ref="input1"
              onBlur={this.showData1}
              type="text"
              placeholder="失去焦点提示数据"
            />
            &nbsp;
          </div>
        );
      }
    }
    //渲染组件到页面
    ReactDOM.render(<Demo />, document.getElementById("test"));
  </script>
</html>
